package com.adnaan.restaurant.mapper;

import com.adnaan.restaurant.entity.SysUser;
import org.apache.ibatis.annotations.*;

/**
 * author: adnaan
 * create: 2023-11-22 15:39
 * Description:
 */
@Mapper
public interface SysUserMapper {

    @Select("select user_id, dept_id, user_name, nick_name, email, avatar, phonenumber, password, sex, status from sys_user where user_name = #{userName}")
    SysUser selectUserByUserName(String userName);

    @Insert("insert into sys_user (user_name, nick_name, email, phonenumber, password, sex, status)" +
            " values(#{userName},#{nickName},#{email},#{phoneNumber},#{password},#{sex},0)")
    int register(SysUser user);

    @Update("update sys_user set nick_name=#{nickName},email=#{email},phonenumber=#{phoneNumber},password=#{password} where user_id = #{userId}")
    int updateUser(SysUser sysUser);

    @Update("update sys_user set avatar = #{avatar} where user_id = #{uid}")
    int updateAvatar(@Param("avatar") String url, @Param("uid") Long userId);

    @Select("select user_id, dept_id, user_name, nick_name, email, avatar, phonenumber, password, sex, status from sys_user where user_id = #{userId}")
    SysUser selectUserByUserId(Long userId);
}
